package com.example.administrator.x3picturetransliteration.Home.Presenter.Activity;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.example.administrator.x3picturetransliteration.Base.BasePresenter;
import com.example.administrator.x3picturetransliteration.Base.HttpGo;
import com.example.administrator.x3picturetransliteration.Bean.AppDataBean;
import com.example.administrator.x3picturetransliteration.Bean.HttpDataBean;
import com.example.administrator.x3picturetransliteration.Constants;

import java.util.HashMap;

import rx.subscriptions.CompositeSubscription;

/**
 * 引导页
 * Created by Administrator on 2019/9/24.
 */

public class MainActivityPresenter extends BasePresenter{

    public MainActivityPresenter(Context context, CompositeSubscription mCompositeSubscription) {
        super(context, mCompositeSubscription);
    }

    public void getAppData(final Callback mCallback){

        mCompositeSubscription.add(

                mHttpGo.postSubscription("sys_aboutus/get", new HashMap<String, String>(),null, new HttpGo.HttpGoCallback() {
                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(HttpDataBean httpDataBean) {

                        if (httpDataBean.getCode()==0){

                            if (httpDataBean.getData()!=null){

                                Constants.getConstants().setmAppDataBean(JSON.parseObject(httpDataBean.getData() + "", new TypeReference<AppDataBean>() {}));
                                mCallback.getData(null);
                            }
                        }
                    }
                })
        );

    }

}
